package net.csdn.business.common.domain.request;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * @author wanghang
 * @version 1.0
 * @date 2022/11/7 15:36
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MilepostSearchDto implements Serializable {

    /** 组织ID/仓库ID */
    @NotBlank(message = "sourceId不能为空")
    private String sourceId;
    /** 1:组织；2:仓库 */
    @NotNull(message = "sourceType不能为空")
    @Range(min = 1, max = 2, message = "sourceType不合法")
    private Integer sourceType;

    private String key;

    /**
     * 状态 null-全部 1-已开启 2-已关闭
     */
    private Integer status;


    @Min(value = 1)
    private Integer pageNum=1;


    @Min(value = 1)
    @Max(value = 100)
    private Integer pageSize=10;


    private List<String> sourceIds;

    /**
     * 排序字段 GOAL_NAME、CREATED_DATE
     */
    private String Sort;

    @Getter
    @AllArgsConstructor
    public static enum SortEnum {
        GOAL_NAME_DESC,
        GOAL_NAME_ASC,
        CREATED_DATE_DESC,
        CREATED_DATE_ASC,
        DEADLINE_DESC,
        DEADLINE_ASC,
        ;

        public static SortEnum ofCode(String sortField) {
            try {
                return SortEnum.valueOf(sortField);
            }catch (Exception e){
                return SortEnum.CREATED_DATE_DESC;
            }
        }
    }


}
